home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Libraries / VideoToolbox 97.08.16 / (Utilities) / ReadLuminanceMeter / PC_folder / MINOLTA_PC.C
Encoding:
C/C++ Source or Header  |  1995-09-28  |  3.7 KB  |  150 lines  |  [TEXT/ttxt]

  1. /*
  2.  
  3.   *********************************
  4.            ReadMinoltaLS110  PC version
  5.     *********************************
  6.  
  7.     C-routines that can be used to read out the Minolta LS-110/LS-100.    
  8.     
  9.     Use at your own risk. Not for sale. May be distributed for non-commercial purposes.
  10.     These routines are not provided by Minolta™ so don't contact them about it.
  11.     Mac version by Frans W. Cornelissen, with suggestions from Eli Brenner.
  12.     Copyrighted by Frans W. Cornelissen. 
  13.     PC version copyrighted by  Erik van Wijk, Fysiology I, Erasmus University Rotterdam,
  14.     The Netherlands. Contact him at wijk@fys1.fgg.eur.nl.
  15.     
  16.     This package should include
  17.     
  18.     read me file
  19.     Minolta.c            C routines for macintosh computer
  20.     Minolta.h            include file for mac
  21.     ReadMinoltaLS110     small example program that works on my Quadra 610 and LC.
  22.     In PC folder
  23.                Minolta_PC.c        routines that should work on pc
  24.     
  25.     Please send suggestions, bugs, improvements, comments to:
  26.  
  27.     Frans W. Cornelissen
  28.     Laboratory for Experimental Ophthalmology (LEO)
  29.     University of Groningen
  30.     P.O. Box 30.001, 9700 RB  Groningen, The Netherlands
  31.     Tel:  + 31 50 614173 (work)
  32.     Fax: + 31 50 696743 (work)
  33.     E-mail: f.w.cornelissen@med.rug.nl
  34.  
  35. PC version by:
  36.  
  37. Erik van Wijk                          vanwijk@fys1.fgg.eur.nl
  38. Vakgroep Fysiologie, EUR               tel: +31-10-4087562
  39. Postbus 1738                           fax: +31-10-4367594
  40. NL 3000 DR  Rotterdam, The Netherlands
  41.  
  42.  
  43.     *************************
  44. PC version
  45.  
  46. Serial interface to LS100. In this software both assembly and borland c code is used
  47. to drive the serial port. Reading of characters is in assembler because the 
  48. borland c bioscom influences the DTR line also. Setting of DTR line can only be
  49. done in assembly. Software only suitable for  COM1(0) or COM2(1)
  50.  
  51.  
  52. Connector pin connections:
  53.     Minolta:        RS232 9 PIN:
  54.  
  55.     pin     colour   pin
  56.     DATA    red    2 (TD)
  57.     MR      white     4 (DTR)
  58.     GND     brown   5 (GND)
  59.  
  60. Other connections
  61. RS232 9 PIN
  62.       7 to 8 (RTS to CTS)
  63.       1 to 6 and also to 4 (DCD to DSR to DTR)
  64. Minolta
  65.       black to yellow (BSY to +5V)
  66.  
  67. */
  68.  
  69.  
  70.     #include        <stdio.h>
  71.     #include        <bios.h>
  72.     #include        <conio.h>
  73.     #include        <dos.h>
  74.     #include        <time.h>
  75.  
  76.     #define _7DATABITS      0x02
  77.     #define _2STOPBITS      0x04
  78.     #define EVENPARITY      0x18
  79.     #define _4800BAUD       0xC0
  80.     #define DATA_READY      0x100
  81.  
  82.  
  83. void readlumdata(int COM,char * string);
  84. void initcom(int COM);
  85.  
  86.  
  87. void main()
  88. {
  89.  
  90. int DONE=0;
  91. char string12[13];
  92.  
  93.  
  94. clrscr();
  95. initcom(1);
  96.  
  97.  
  98. while(!DONE)
  99.         { if(kbhit())
  100.           { getch();
  101.              puts("go");
  102.              readlumdata(1,string12);
  103.              printf("%s",string12 );
  104.             }
  105.         }
  106. }
  107.  
  108. void initcom(int COM)
  109. { if(COM) asm mov dx,2fch        //force DTR/ and RTS/ low
  110.     else asm mov dx,3fch
  111.     asm{ mov al,0           //2=RTS 1=DTR
  112.           out dx,al
  113.         }
  114.     bioscom(0, _4800BAUD | EVENPARITY | _2STOPBITS  | _7DATABITS , 
  115. COM);
  116. }
  117.  
  118.  
  119. void readlumdata(int COM, char *string)
  120. {
  121.      int i,status;
  122.      char character;
  123.      //alleen geschikt voor COM1 of COM2
  124.      //geef signaal aan meter om meting te starten
  125.      if(COM)asm mov dx,2fch           //force DTR/ and RTS/ low
  126.      else asm mov dx,3fch
  127.      asm  { mov al,1          //2=RTS 1=DTR
  128.               out dx,al
  129.             }
  130.  
  131.      for(i=0;i<11;i++)
  132.             while(! ( (status = bioscom(3,0,COM)) & DATA_READY)  );
  133.             if(COM)asm mov dx,2f8h
  134.             else asm mov dx,3f8h
  135.             asm { in al,dx
  136.                     mov character,al
  137.                  }
  138.             *(string+i)=(char)character;
  139.  
  140.      *(string+i)='\0';
  141.      if (COM) asm mov dx,2fch
  142.      else asm mov dx,3fch
  143.      asm  { mov al,0          //2=RTS 1=DTR
  144.               out dx,al
  145.             }
  146.  
  147.  
  148.  
  149.